<template>
  <div class="app-container">
    <el-tabs v-model="activityType" @tab-click="handleClick">
      <el-tab-pane
        v-for="item in allTabs"
        :key="item.id"
        :label="item.menuName"
        :name="String(item.id)"
      ></el-tab-pane>
    </el-tabs>
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="预约编号" prop="code">
        <el-input
          v-model="queryParams.code"
          placeholder="请输入预约编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="活动名称" prop="activityName">
        <el-input
          v-model="queryParams.activityName"
          placeholder="请输入活动名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="活动日期" prop="activityDate">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="活动场次" prop="activityYardTimes">
        <el-input
          v-model="queryParams.activityYardTimes"
          placeholder="请输入活动场次"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--            <el-form-item label="联系电话" v-if="activityType == 2" prop="mobile">-->
      <!--                <el-input v-model="queryParams.mobile" placeholder="请输入联系电话" clearable-->
      <!--                    @keyup.enter.native="handleQuery" />-->
      <!--            </el-form-item>-->
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          >导出</el-button
        >
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="orderList"
      @selection-change="handleSelectionChange"
    >
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="预约编号" align="center" prop="code" />
      <el-table-column label="活动名称" align="center" prop="activityName" />
      <!-- 添加三级菜单列，仅在非互动体验情况下显示 -->
      <el-table-column
        label="三级菜单"
        align="center"
        v-if="activityType != '1'"
      >
        <template slot-scope="scope">
          {{ getActivityMenuName(scope.row.activityMenuId) }}
        </template>
      </el-table-column>
      <el-table-column
        label="活动日期"
        align="center"
        prop="activityDate"
        width="180"
      />
      <el-table-column
        label="活动场次"
        align="center"
        prop="activityYardTimes"
      />
      <el-table-column
        :label="this.activityType == '1' ? '取号人数' : '参加人数'"
        align="center"
        prop="num"
      />
      <el-table-column label="提交时间" align="center" prop="submitDate" />
      <!--            <el-table-column :formatter="statusFormatter" label="预约状态" align="center" prop="status" />-->
      <el-table-column
        :formatter="getStatusFormatter"
        :label="this.activityType == '1' ? '取号状态' : '预约状态'"
        align="center"
        prop="status"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleView(scope.row)"
            >查看</el-button
          >

          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改预约（个人）对话框 -->
    <!--        <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>-->
    <!--            <el-form :inline="true" ref="form" :model="form" :rules="rules" label-width="80px">-->
    <!--                <el-form-item label="预约编号" prop="code">-->
    <!--                    <el-input v-model="form.code" placeholder="请输入预约编号" />-->
    <!--                </el-form-item>-->
    <!--                <el-form-item label="预约状态" prop="statusName">-->
    <!--                    <el-input v-model="form.statusName" placeholder="请输入预约状态" />-->
    <!--                </el-form-item>-->
    <!--                <el-form-item label="参加人数" prop="num">-->
    <!--                    <el-input v-model="form.num" placeholder="请输入参加人数" />-->
    <!--                </el-form-item>-->

    <!--                <el-form-item label="活动名称" prop="activityName">-->
    <!--                    <el-input v-model="form.activityName" placeholder="请输入活动名称" />-->
    <!--                </el-form-item>-->
    <!--                <el-form-item label="活动日期" prop="activityDate">-->
    <!--                    <el-input v-model="form.activityDate" placeholder="请输入活动日期" />-->
    <!--                </el-form-item>-->
    <!--                <el-form-item label="活动场次" prop="activityYardTimes">-->
    <!--                    <el-input v-model="form.activityYardTimes" placeholder="请输入活动场次" />-->
    <!--                </el-form-item>-->

    <!--                <el-form-item label="用户名称" prop="trueName">-->
    <!--                    <el-input v-model="form.trueName" placeholder="请输入用户名称" />-->
    <!--                </el-form-item>-->
    <!--                <el-form-item label="证件类型" prop="idTypeName">-->
    <!--                    <el-input v-model="form.idTypeName" placeholder="请输入证件类型" />-->
    <!--                </el-form-item>-->
    <!--                <el-form-item label="证件号码" prop="idNo">-->
    <!--                    <el-input v-model="form.idNo" placeholder="请输入证件号码" />-->
    <!--                </el-form-item>-->

    <!--                <el-form-item label="联系电话" prop="mobile">-->
    <!--                    <el-input v-model="form.mobile" placeholder="请输入联系电话" />-->
    <!--                </el-form-item>-->
    <!--                <el-form-item label="预约时间" prop="orderDate">-->
    <!--                    <el-input v-model="form.orderDate" placeholder="请输入预约时间" />-->
    <!--                </el-form-item>-->
    <!--                <el-form-item label="提交时间" prop="submitDate">-->
    <!--                    <el-input v-model="form.submitDate" placeholder="请输入提交时间" />-->
    <!--                </el-form-item>-->
    <!--            </el-form>-->

    <!--            <div>参与人员</div>-->
    <!--            <el-table v-loading="loading1" :data="orderList1">-->
    <!--                <el-table-column label="姓名" align="center" prop="trueName" />-->
    <!--                <el-table-column :formatter="idTypeFormatter" label="证件类型" align="center" prop="idType" />-->
    <!--                <el-table-column label="证件号码" align="center" prop="idNo" />-->
    <!--                <el-table-column :formatter="statusFormatter" label="状态" align="center" prop="status" />-->
    <!--                &lt;!&ndash; <el-table-column label="二维码" align="center" prop="qrUrl" /> &ndash;&gt;-->
    <!--            </el-table>-->
    <!--            <pagination v-show="total1 > 0" :total="total1" :page.sync="queryParams1.pageNum"-->
    <!--                :limit.sync="queryParams1.pageSize" @pagination="getList1" />-->

    <!--            <div slot="footer" class="dialog-footer">-->
    <!--                &lt;!&ndash; <el-button type="primary" @click="submitForm">确 定</el-button> &ndash;&gt;-->
    <!--                <el-button @click="cancel">取 消</el-button>-->
    <!--            </div>-->
    <!--        </el-dialog>-->

    <el-dialog
      :title="title"
      :visible.sync="jVisible"
      width="1000px"
      append-to-body
    >
      <el-form
        :inline="true"
        ref="form"
        :model="form"
        :rules="rules"
        label-width="80px"
      >
        <el-form-item label="预约编号" prop="code">
          <el-input v-model="form.code" readonly />
        </el-form-item>
        <el-form-item label="预约状态" prop="statusName">
          <el-input v-model="form.statusName" readonly />
        </el-form-item>
        <el-form-item label="参加人数" prop="num">
          <el-input v-model="form.num" readonly />
        </el-form-item>

        <el-form-item label="活动名称" prop="activityName">
          <el-input v-model="form.activityName" readonly />
        </el-form-item>
        <el-form-item label="活动日期" prop="activityDate">
          <el-input v-model="form.activityDate" readonly />
        </el-form-item>
        <el-form-item label="活动场次" prop="activityYardTimes">
          <el-input v-model="form.activityYardTimes" readonly />
        </el-form-item>

        <el-form-item label="联系电话" prop="mobile">
          <el-input v-model="form.mobile" readonly />
        </el-form-item>
        <el-form-item label="预约时间" prop="orderDate">
          <el-input v-model="form.orderDate" readonly />
        </el-form-item>
        <el-form-item label="提交时间" prop="submitDate">
          <el-input v-model="form.submitDate" readonly />
        </el-form-item>
      </el-form>

      <div>参与人员</div>
      <el-table v-loading="loading1" :data="orderList1">
        <el-table-column label="姓名" align="center" prop="trueName" />
        <el-table-column label="出生日期" align="center" prop="birthday" />
        <el-table-column
          :formatter="statusFormatter"
          label="状态"
          align="center"
          prop="status"
        />
      </el-table>
      <pagination
        v-show="total1 > 0"
        :total="total1"
        :page.sync="queryParams1.pageNum"
        :limit.sync="queryParams1.pageSize"
        @pagination="getList1"
      />

      <div slot="footer" class="dialog-footer">
        <!-- <el-button type="primary" @click="submitForm">确 定</el-button> -->
        <el-button @click="cancelJDetail">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      :title="title"
      :visible.sync="hVisible"
      width="1000px"
      append-to-body
    >
      <el-descriptions title="活动信息" :column="2">
        <el-descriptions-item label="活动名称">{{
          form.code
        }}</el-descriptions-item>
        <el-descriptions-item label="活动日期">{{
          form.activityDate
        }}</el-descriptions-item>
        <el-descriptions-item label="活动场次">{{
          form.activityYardTimes
        }}</el-descriptions-item>
        <el-descriptions-item label="活动时间"
          >{{ form.activityStartTime }}-{{
            form.activityEndTime
          }}</el-descriptions-item
        >
        <el-descriptions-item
          label="活动地点"
          :span="2"
          v-if="form.activityInfo"
        >
          {{ form.activityInfo.activityPlace }}
        </el-descriptions-item>
      </el-descriptions>
      <el-descriptions title="排队取号信息" :column="2">
        <!-- <el-descriptions-item label="联系电话">{{ form.mobile }}</el-descriptions-item> -->
        <el-descriptions-item label="编号">{{
          form.code
        }}</el-descriptions-item>
        <el-descriptions-item label="取号人数">{{
          form.num
        }}</el-descriptions-item>
        <el-descriptions-item label="取号号码" v-if="form.list">{{
          form.list.map((s) => s.numbers).join(",")
        }}</el-descriptions-item>
        <el-descriptions-item label="取号状态" :span="2">
          {{ getStatusFormatter(null, null, form.status) }}
        </el-descriptions-item>
        <el-descriptions-item label="创建时间" :span="2">
          {{ form.list && form.list[0].createTime }}
        </el-descriptions-item>
      </el-descriptions>
    </el-dialog>
  </div>
</template>

<script>
import {
  listOrder,
  getOrderById,
  delOrder,
  addOrder,
  updateOrder,
} from "@/api/system/order";
import { listByOrderId } from "@/api/system/detail";
import store from "@/store";
import { getMenuTree, getListByParentId } from "@/api/activityMenu";

export default {
  name: "Order",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 预约（个人）表格数据
      orderList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      hVisible: false,
      jVisible: false,
      // 查询参数
      dateRange: "",
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        code: null,
        num: null,
        activityId: null,
        activityName: null,
        activityDate: null,
        activityStartTime: null,
        activityEndTime: null,
        activityYardTimes: null,
        trueName: null,
        idType: null,
        idNo: null,
        mobile: null,
        orderDate: null,
        submitDate: null,
        status: null,
        completeDate: null,
        cancelDate: null,
        isDel: null,
        version: null,
        createUserId: null,
        createUserName: null,
        updateUserId: null,
        updateUserName: null,
        activityMenuId: "1", // 新增参数，默认为"1"
      },

      queryParams1: {
        pageNum: 1,
        pageSize: 10,
        orderId: null,
      },
      loading1: true,
      // 总条数
      total1: 0,
      // 预约（个人）表格数据
      orderList1: [],

      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      activityType: "1",
      menuList: [], // 新增菜单列表
      // 添加活动菜单列表和缓存
      activityMenuList: [],
      activityMenuCache: {},
    };
  },
  computed: {
    allTabs() {
      // 合并固定标签和动态菜单标签
      return [{ id: "1", menuName: "互动体验" }].concat(this.menuList);
    },
  },
  async created() {
    // 先获取菜单数据
    await this.getMenuData();
    // 确保初始的activityType与初始选中标签页的ID一致
    this.activityType = String(this.queryParams.activityMenuId);
    
    // 如果不是互动体验，加载三级菜单
    if (this.activityType !== "1") {
      getListByParentId(this.activityType).then(res => {
        if (res.code === 200) {
          // 处理返回的rows数据
          const menuList = (res.rows || []).map(item => ({
            label: item.menuName,
            value: item.id
          }));
          
          // 保存到缓存
          this.activityMenuCache[this.activityType] = menuList;
          this.activityMenuList = menuList;
        }
      });
    }
    
    this.getList();
  },
  methods: {
    // 获取菜单数据
    getMenuData() {
      return new Promise((resolve) => {
        getMenuTree().then((res) => {
          if (res.code === 200 && res.data) {
            // 确保所有id都是字符串
            this.menuList = res.data.map(item => ({
              ...item,
              id: String(item.id) // 转换id为字符串
            }));
          }
          resolve();
        });
      });
    },
    statusFormatter(row, column, cellValue) {
      if (cellValue == "1") {
        return "已取消";
      }
      if (cellValue == "2") {
        return "未完成";
      }
      if (cellValue == "3") {
        return "已完成";
      }
      return "";
    },
    getStatusFormatter(row, column, cellValue) {
      // 根据activityType判断状态显示
      // 如果是互动体验(id=1)，则显示取号状态
      // 其他则显示预约状态
      if (this.activityType == "1") {
        if (cellValue == "1") {
          return "已取消";
        }
        if (cellValue == "2") {
          return "已取号";
        }
        if (cellValue == "3") {
          return "已完成";
        }
        return "";
      } else {
        if (cellValue == "1") {
          return "已取消";
        }
        if (cellValue == "2") {
          return "未完成";
        }
        if (cellValue == "3") {
          return "已完成";
        }
        return "";
      }
    },

    idTypeFormatter(row, column, cellValue) {
      if (cellValue == "1") {
        return "身份证";
      } else if (cellValue == "2") {
        return "港澳通行证";
      } else if (cellValue == "3") {
        return "台湾通行证";
      } else if (cellValue == "4") {
        return "护照";
      } else if (cellValue == "5") {
        return "外国人永居证";
      }
      return "";
    },
    /** 查询预约（个人）列表 */
    getList() {
      this.loading = true;
      if (this.dateRange) {
        this.queryParams.activityDateStart = this.dateRange[0] + " 00:00:00";
        this.queryParams.activityDateEnd = this.dateRange[1] + " 23:59:59";
      } else {
        this.queryParams.activityDateStart = "";
        this.queryParams.activityDateEnd = "";
      }
      
      // 设置activityMenuId为当前标签页ID
      this.queryParams.activityMenuId = String(this.activityType);
      
      // 根据当前选中的标签页ID判断activityType
      // 如果是互动体验(id=1)，则activityType=1，否则activityType=2
      const realActivityType = this.activityType === "1" ? "1" : "2";
      
      let params = {
        ...this.queryParams,
        activityType: realActivityType
      };
      
      listOrder(params).then((response) => {
        this.orderList = response.rows.map((item) => {
          return item;
        });
        this.total = response.total;
        this.loading = false;
      });
    },
    getList1() {
      this.loading1 = true;
      listByOrderId(this.queryParams1).then((response) => {
        this.orderList1 = response.rows.map((item) => {
          if (store.getters.isShowCard == "0" && item.idNo) {
            item.idNo = item.idNo.replace(
              /^(.{6})(?:\w+)(.{4})$/,
              "$1********$2"
            );
            // item.mobile = item.mobile.replace(/^(.{3})(?:\d+)(.{4})$/, "$1****$2")
          }
          return item;
        });
        this.total1 = response.total;
        this.loading1 = false;
      });
    },
    cancelJDetail() {
      this.jVisible = false;
      this.reset();
    },
    cancelHDetail() {
      this.hVisible = false;
      this.reset();
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        code: null,
        num: null,
        activityId: null,
        activityName: null,
        activityDate: null,
        activityStartTime: null,
        activityEndTime: null,
        activityYardTimes: null,
        trueName: null,
        idType: null,
        idNo: null,
        mobile: null,
        orderDate: null,
        submitDate: null,
        status: "0",
        completeDate: null,
        cancelDate: null,
        isDel: null,
        version: null,
        createUserId: null,
        createUserName: null,
        createTime: null,
        updateUserId: null,
        updateUserName: null,
        updateTime: null,
      };
      this.dateRange = "";
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      
      // 如果不是互动体验标签页，确保已加载对应的三级菜单列表
      if (this.activityType !== "1") {
        // 确认当前是否已有缓存数据
        if (!this.activityMenuCache[this.activityType]) {
          console.log('查询时加载三级菜单数据，parentId:', this.activityType);
          // GET请求获取三级菜单数据
          getListByParentId(this.activityType).then(res => {
            console.log('三级菜单数据:', res);
            if (res.code === 200) {
              // 处理返回的rows数据
              const menuList = (res.rows || []).map(item => ({
                label: item.menuName,
                value: item.id
              }));
              
              // 保存到缓存
              this.activityMenuCache[this.activityType] = menuList;
              this.activityMenuList = menuList;
            }
          });
        }
      }
      
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      // 保存当前的activityMenuId
      const currentMenuId = this.queryParams.activityMenuId || "1";
      this.resetForm("queryForm");
      this.dateRange = "";
      // 重置后恢复activityMenuId
      this.queryParams.activityMenuId = currentMenuId;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加预约（个人）";
    },
    /** 查看按钮操作 */
    handleView(row) {
      this.reset();
      const id = row.id || this.ids;
      getOrderById(id).then((response) => {
        this.form = response.data;
        if (store.getters.isShowCard == "0" && this.form && this.form.idNo) {
          this.form.idNo = this.form.idNo.replace(
            /^(.{6})(?:\w+)(.{4})$/,
            "$1********$2"
          );
        }
        // if (store.getters.isShowCard == '0' && this.form && this.form.mobile) {
        //     this.form.mobile = this.form.mobile.replace(/^(.{3})(?:\d+)(.{4})$/, "$1****$2")
        // }

        if (this.activityType == "1") {
          if (this.form.status == "1") {
            this.form.statusName = "已取消";
          } else if (this.form.status == "2") {
            this.form.statusName = "已取号";
          }else if (this.form.status == "3") {
            this.form.statusName = "已完成";
          }
        } else {
          if (this.form.status == "1") {
            this.form.statusName = "已取消";
          } else if (this.form.status == "2") {
            this.form.statusName = "未完成";
          } else if (this.form.status == "3") {
            this.form.statusName = "已完成";
          }
        }

        if (this.form.idType == "1") {
          this.form.idTypeName = "身份证";
        }
        if (this.form.idType == "2") {
          this.form.idTypeName = "港澳通行证";
        }
        if (this.form.idType == "3") {
          this.form.idTypeName = "台湾通行证";
        }
        if (this.form.idType == "4") {
          this.form.idTypeName = "护照";
        }
        if (this.form.idType == "5") {
          this.form.idTypeName = "外国人永居证";
        }

        this.queryParams1.orderId = id;
        this.queryParams1.pageNum = 1;
        this.getList1();

        // 修改活动类型判断逻辑
        // 如果是互动体验(id=1)则显示排队取号信息，否则显示预约信息
        if (this.activityType == "1") {
          this.hVisible = true;
        } else {
          this.jVisible = true;
        }

        this.title = "查看预约";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateOrder(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrder(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除预约（个人）编号为"' + ids + '"的数据项？')
        .then(function () {
          return delOrder(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      // 根据当前选中的标签页ID判断activityType
      // 如果是互动体验(id=1)，则activityType=1，否则activityType=2
      const realActivityType = this.activityType === "1" ? "1" : "2";
      
      // 设置导出参数
      const exportParams = {
        ...this.queryParams,
        activityType: realActivityType,
        activityMenuId: String(this.activityType)
      };
      
      if (this.activityType == "1") {
        this.download(
          "system/order/export",
          exportParams,
          `order_${new Date().getTime()}.xlsx`
        );
      } else {
        this.download(
          "system/order/skillWorkshopExport",
          exportParams,
          `skill_${new Date().getTime()}.xlsx`
        );
      }
    },
    handleClick(tab) {
      // 确保将tab.name转换为字符串类型
      const tabId = String(tab.name);
      console.log('切换到标签页:', tabId);
      
      // 设置activityType为当前标签页的ID
      this.activityType = tabId;
      
      // 设置activityMenuId为当前标签页ID
      this.queryParams.activityMenuId = tabId;
      
      // 重置查询条件
      this.queryParams.code = null;
      this.queryParams.activityName = null;
      this.queryParams.activityYardTimes = null;
      this.dateRange = "";
      this.queryParams.status = null;
      
      // 如果不是互动体验标签页，加载对应的三级菜单列表
      if (tabId !== "1") {
        console.log('加载三级菜单数据，parentId:', tabId);
        // GET请求获取三级菜单数据
        getListByParentId(tabId).then(res => {
          console.log('三级菜单数据:', res);
          if (res.code === 200) {
            // 处理返回的rows数据
            const menuList = (res.rows || []).map(item => ({
              label: item.menuName,
              value: item.id
            }));
            
            // 保存到缓存
            this.activityMenuCache[tabId] = menuList;
            this.activityMenuList = menuList;
          }
        });
      }
      
      // 获取列表数据
      this.getList();
    },
    // 根据activityMenuId获取活动类型名称
    getActivityMenuName(menuId) {
      if (!menuId) return '未分类';
      
      // 如果activityMenuList已加载，直接查找
      if (this.menuList && this.menuList.length > 0) {
        const menu = this.menuList.find(item => String(item.value) === String(menuId));
        if (menu) {
          return menu.label;
        }
      }
      
      // 如果是当前父级下的缓存，检查缓存
      if (this.activityMenuCache[this.activityType]) {
        const menu = this.activityMenuCache[this.activityType].find(
          item => String(item.value) === String(menuId)
        );
        if (menu) {
          return menu.label;
        }
      }
      
      // 如果未找到，返回ID
      return menuId;
    },
  },
};
</script>
